/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.training.conditions;

import soccerscope.model.ClientScene;
import soccerscope.model.WorldModel;

public class CycleCondition extends GameCondition {

	private int cycles = 10;

	private int current = 0;

	public CycleCondition() {
		super();
	}

	public void setCycles(int i) {
		this.cycles = Math.abs(i);
		System.out.println("Cycles: " + this.cycles);
	}

	public int getCycles() {
		return this.cycles;
	}

	/**
	 * This method ovverrides the isTrue() method from gamecondition to specifiy
	 * the behaviour of the cycle-condition.
	 */
	@Override
	public boolean isTrue(ClientScene scene) {
		this.current++;
		if (this.current >= this.cycles) {
			System.out.println(""
					+ WorldModel.getInstance().getSceneSet().lastScene().time
					+ " Cycle condition satisfied");
			return true;
		}
		return false;
	}

	/**
	 * Sets the current-counter (cycle-counter) to zero
	 */
	@Override
	public void resetCondition() {
		this.current = 0;
	}

	public int getStatIndex() {
		return 1;
	}

}
